﻿using System;
using System.Web.UI;
using WebUI.BL.Member;
using WebUI.DAL;

namespace WebUI.UserControls
{
    public partial class UCLogin : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            MemberBL member = new MemberBL();
            string email = txtEmail.Text.Trim();
            string password = txtPassword.Text.Trim();
            string name = member.checkLogin(email, password);
            if (name == "" || name == null)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "ReviewAdd", "alert('Email or Password is not correct!');", true);
                return;
            }
            else
            {
                Response.Cookies.Get("adler_email").Value = email;
                Response.Cookies.Get("adler_email").Expires = DateTime.Now.AddHours(24);

                Response.Cookies.Get("adler_name").Value = name;
                Response.Cookies.Get("adler_name").Expires = DateTime.Now.AddHours(24);
                Response.Redirect("/Default.aspx");
            }
        }
    }
}